<?php
my_component_load('testing' , false);
my_component_load('paging' , false);   
my_component_load('data_setting', false);
my_component_load('list_kalender' , false);   
my_component_load('kalendar_shift' );
$task = isset($_GET['task']) ? $_GET['task'] : "";  
$tanggal = isset($_GET['tanggal']) ? $_GET['tanggal'] : "";  
$value = isset($_GET['value']) ? $_GET['value'] : "";  
$id = isset( $_GET['id'] ) ? $_GET['id']:  0;
$kid = isset( $_GET['kid'] ) ? $_GET['kid']:  0;
$periode_id = isset( $_GET['periode_id'] ) ? $_GET['periode_id']:  0;
$kelompok_shift_id = isset( $_GET['kelompok_shift_id'] ) ? $_GET['kelompok_shift_id']:  0;

$modulname = "Personalia _BN_ Waktu Kerja _BN_ Jadwal Kerja _BN_ Create Group Schedule";
if($_SERVER['REQUEST_METHOD'] == "POST" ):
	if($task=='create_group_page'){
		$validatepost = create_group_validate($periode_id);
		if($validatepost){
			$errors = message_multi_error($validatepost);
			$content = $errors;
			$content .= form_create_group($periode_id);
			generate_my_web($content,"","plain.php");
			exit; 
		}else {
			submit_group($periode_id); 
			$content =  "Updated";
			generate_my_web($content,"","plain.php");
			exit;
		}
		break; 	
	}
	my_direct('index.php?com=kalender_shift');
	break;	
else: 
	if($task == "detail_kelompok"){
		facebox_page( 'index.php?com='.$_GET['com'].'&task=detail_kelompok_page&periode_id='.$_GET['periode_id'].'&kelompok_shift_id='.$_GET['kelompok_shift_id'],  ' ', 450	);
	}elseif($task == "detail_kelompok_page"){
			$pagename = $modulname." _BN_ Detail _BN_ Setting Jadwal Kerja";
			$view =  detail_kelompok_shift($periode_id ,$kelompok_shift_id);
			generate_my_web($view,"","plain.php");
			exit;				
	}elseif($task =="detail"){
		load_facebox_script();
			$pagename = $modulname." _BN_ Detail";
			$view =  list_kelompok_shift($periode_id);
				
	}elseif($task =="update"){
			update_tanggal_shift($tanggal , $periode_id , $kelompok_shift_id , $value);
			my_direct($_SERVER['HTTP_REFERER']);
			break;
	}elseif($task == 'create_schedule'){ 
			form_generate_kalender_shift() ;
			my_direct($_SERVER['HTTP_REFERER']);
			break;
	}elseif($task == 'delete'){
		remove_group($id);
		my_direct('index.php?com=kalendar_shift&task=detail&periode_id='.$periode_id);
	}elseif($task =='create_group'){	
		$pagename = $modulname." _BN_ Create";
		facebox_page('index.php?com=kalendar_shift&task=create_group_page&periode_id='.$periode_id  , $title , 280	); 
	}elseif($task == 'create_group_page'){
		$content  = form_create_group($periode_id);
		generate_my_web($content,"","plain.php");
		exit; 		
		
	}else{
			$pagename = $modulname;
			load_facebox_script();
			$view =  list_kalendar_periode();
			$href = 'index.php?com=kalendar_shift&task=create' ;
	}
	generate_my_web($view , $pagename );	
endif; 


